package com.emailsystem.emailsystem.service.impl.client;

//import org.json.simple.JSONObject;

import com.alibaba.fastjson.JSONObject;

import java.io.ObjectOutputStream;
import java.net.Socket;

public class Client_send implements Runnable{
    private Socket socket;
    private ObjectOutputStream oos;
    private oldClientServiceImpl clientService;

    private JSONObject object;

    Client_send(Socket socket, ObjectOutputStream oos, JSONObject object){
        this.socket = socket;
        this.oos = oos;
        this.object = object;
    }

    @Override
    public void run() {
        try {
                oos.writeObject(this.object);
                oos.flush();
        }catch (Exception e){
            e.printStackTrace();
            try {
                socket.close();
                oldClientServiceImpl.setState(false);
                oldClientServiceImpl.connect(oldClientServiceImpl.getConnection(), this.object,1);
            }catch (Exception ee){
                ee.printStackTrace();
            }
        }
    }
}
